<template>
	<view class="content">
		<u--input placeholder="请输入标题" border="surround" v-model="addTitle" ></u--input>
		<view style="height: 40rpx;"></view>
		<u--textarea v-model="addContent" placeholder="请输入内容" :count="true" :height="100"></u--textarea>
		<view style="height: 40rpx;"></view>
		<u-button type="primary" text="确定" @click="addTask"></u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				addTitle: '',
				addContent: '',
			}
		},
		methods: {
			// 添加任务到云端数据库
			addTask() {
				uniCloud.callFunction({
					name: 'task',
					data: {
						action: 'add',
						title: this.addTitle,
						content: this.addContent
					},
					success: (e) => {
						uni.showToast({
							title: "添加成功"
						})
						// 页面跳转返回
						uni.navigateBack()
					}
				})
			}
		}
	}
</script>

<style>
 .content {
	 padding: 40rpx;
 }
</style>
